import Base from "../base.js";
import UsersApi from "../../api/users.js";

export default class extends Base {
  render() {
    this.$el.html(`
    <section class="w3l-login">
		<div class="overlay">
			<div class="wrapper">
				<div class="logo">
				</div>
				<div class="form-section">
				<h3><img src="../../../static/html/images/123.png" alt=""></h3>
		
						<div class="form-input">
							<input type="text" name="usersname" placeholder="请输入账号"  >
						</div>
						<div class="form-input">
							<input type="password" name="password" placeholder="密码" >
						</div>
						<div class="form-input">
							<input type="password" name="phone" placeholder="请输入手机号" >
						</div>
						<div>
						<button class=" btn-primary theme-button ">获取验证码</button>	<input type="password" name="phone" placeholder="请输入验证码"  id="useNum">
						</div>
						<button class="btn btn-primary theme-button mt-4" id="reg-btn">完成注册并登录</button>
				
				</div>
			</div>
		</div>
	  <div id="stars"></div>
    <div id="stars2"></div>
    <div id="stars3"></div>
	</section>

        `)
    this.$usersnameEle = $("input[name=usersname]");
    this.$passwordEle = $("input[name=password]");
    this.$regBtn = $("#reg-btn");
  }

 
  async regHandle() {
    let usersname = this.$usersnameEle.val();
    let password = this.$passwordEle.val();
	console.log({usersname,password});
    const status = await UsersApi.reg({ usersname, password })
	console.log(status)
	if(status){
		alert("注册成功")
		location.hash="#/usersLogin"
	}else{
		alert("注册失败")
	}

  }
  handle() {

    this.$regBtn.on("click", this.regHandle.bind(this));
  }


  
}














